# -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.auth.models import User
from congreso.trabajos.models import *

class SubAreaAdmin(admin.ModelAdmin):
    search_fields = ('sub_area', 'area')
    list_display = ('sub_area', 'area',)
    list_filter = ('area',)
    ordering = ('sub_area',)

class StatusAdmin(admin.ModelAdmin):
    search_fields = ('status',)
    list_display = ('id', 'status',)
    list_display_links = ('id', 'status',)
    list_filter = ('status',)
    ordering = ('id',)

class ContactAdmin(admin.ModelAdmin):
    search_fields = ('contact',)
    list_display = ('contact', 'first_name', 'last_name', 'email', 'area', 'sub_area',)
    list_filter = ('area', 'sub_area',)
    ordering = ('contact',)

    def first_name(self, obj):
        if obj.contact.first_name:
            return '%s' % (obj.contact.first_name)
        else:
            return None
    first_name.allow_tags = True
    first_name.short_description = 'Fist Name'

    def last_name(self, obj):
        if obj.contact.last_name:
            return '%s' % (obj.contact.last_name)
        else:
            return None
    last_name.allow_tags = True
    last_name.short_description = 'Last Name'

    def email(self, obj):
        if obj.contact.email:
            return '%s' % (obj.contact.email)
        else:
            return None
    email.allow_tags = True
    email.short_description = 'Email'

admin.site.register(Dissertation)
admin.site.register(Area)
admin.site.register(SubArea, SubAreaAdmin)
admin.site.register(Status, StatusAdmin)
admin.site.register(Contact, ContactAdmin)
#admin.site.register(Comment)
